package io.renren.modules.listinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.bindinfo.entity.BindinfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.listinfo.entity.ListinfoEntity;
import io.renren.modules.listinfo.service.ListinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-01-04 19:51:39
 */
@RestController
@RequestMapping("listinfo/listinfo")
public class ListinfoController {
    @Autowired
    private ListinfoService listinfoService;

    @GetMapping("getlistinfo")
    public List<ListinfoEntity> getlistinfo(@RequestParam(value = "listNo",required = false) String listNo, @RequestParam(value = "listProject",required = false) String listProject, @RequestParam(value = "empName",required = false) String empName, @RequestParam(value = "listState",required = false) String listState){
        return listinfoService.getlistinfo(listNo,listProject,empName,listState);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("listinfo:listinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = listinfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{listid}")
    @RequiresPermissions("listinfo:listinfo:info")
    public R info(@PathVariable("listid") Integer listid){
		ListinfoEntity listinfo = listinfoService.getById(listid);

        return R.ok().put("listinfo", listinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("listinfo:listinfo:save")
    public R save(@RequestBody ListinfoEntity listinfo){
		listinfoService.save(listinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("listinfo:listinfo:update")
    public R update(@RequestBody ListinfoEntity listinfo){
		listinfoService.updateById(listinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("listinfo:listinfo:delete")
    public R delete(@RequestBody Integer[] listids){
		listinfoService.removeByIds(Arrays.asList(listids));

        return R.ok();
    }

}
